//删除关注好友
function cancelFriend(userId,obj){
if(art.dialog.confirm('确认解除好友关系？',function(){
		$.ajax({
			   type: "POST",
			   dataType:'json',
			   url: "friend_friends_dealRelation.htm",
			   data:{'sysUserId':userId,'type':'cancel'},
			   success:function(data){
			   		if(data.result){
			   			$("#user_"+userId).parent().html('<a class="followed" href="javascript:showGroup('+userId+',this)" id="user_'+userId+'">贴条</a>');
			   		}else{
			   			alert("取消关注失败");
			   		}
			   }
		 });
	}
));
}
//贴条时显示当前所有的好友分组
function showGroup(userId) {
	$.post('friend_friends_userGroup.htm',{userId:userId},function(data){
		$.dialog({
		    padding: 0,
		    id:"user_Id_"+userId,
		    width:400,
		    title: '贴条',
		    content: data,
		    lock: true
		});
	});
}
// 添加好友分组
function addFav() {
	if(isEmptyStr($('#new_fav').val())) {
		return ;
	}
	$.ajax({
	   type: "POST",
	   dataType:'json',
	   url: "friend_friends_addGroup.htm",
	   data:{name:$('#new_fav').val()},
	   success:function(data){
	   		if(data.result) {
				$("#my_fav_list").append('<a href="javascript:attenUser('+ data.groupId +');">'+ $('#new_fav').val() +'</a>');
				$('#new_fav').val('');
			}else {
				alert(data.message);
			}
	   }
	});
}
//贴条
function attenUser(groupId) {
	var userId = $("#hiddenUserId").val();
	 $.ajax({
	   type: "POST",
	   dataType:'json',
	   url: "friend_friends_dealRelation.htm",
	   data:{'sysUserId':userId,'groupId':groupId},
	   success:function(data){
	   		if(data.result){
	   			var html = '<a class="followed" href="#">已贴条</a><a href="javascript:cancelFriend('+userId+',this)" class="followeo" id="user_'+userId+'">撕条</a>'
	   			$("#user_"+userId).parent().html(html);
	   			$.dialog.list['user_Id_'+userId].close();
	   		}else{
	   			alert("关注失败");
	   		}
	   }
 });
} 
